home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / makemdi2.zip / RIBBON.C < prev    next >
C/C++ Source or Header  |  1992-11-25  |  4KB  |  154 lines

  1. #define _RIBBON_C
  2. //----------------------------------------------------------------- 
  3. // MAKEMDI adaptation of Windows 3.1 SDK MAKEAPP system. 
  4. // 
  5. // MDI application design based on Chapter 7 of     
  6. // "Windows 3: A Developer's Guide" by Jeffrey Richter. 
  7. // 
  8. // Adaptation developed with permission of the author by  
  9. // John F. Holliday, Technisoft Corporation 
  10. // Telephone: (515) 472-9803, CompuServe: 71271,634 
  11. //
  12. // [DMM]    25-Nov-1992: Fixed crashing on exit
  13. //            Also tabified file to tabsize of 4
  14. //
  15. //            David M. Miller, Business Visions, Inc.
  16. //            Telephone: (212) 747-6118
  17. //            CompuServe: 72676,327
  18. //            internet: dmiller@hera.sbi.com
  19. //----------------------------------------------------------------- 
  20. #include "makemdi.h"
  21.  
  22.  
  23. static BOOL fDefDlgEx = FALSE;
  24.  
  25.  
  26.  
  27. BOOL CALLBACK _export Ribbon_DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  28. {
  29.     CheckDefDlgRecursion(&fDefDlgEx);
  30.     return SetDlgMsgResult(hwndDlg, msg, RibbonDlg_DlgProc(hwndDlg, msg, wParam, lParam));
  31. }
  32.  
  33.  
  34.  
  35.  
  36. LRESULT    RibbonDlg_DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  37. {
  38.     switch (msg) {
  39.         HANDLE_MSG(hwndDlg, WM_INITDIALOG, RibbonDlg_OnInitDialog);
  40.         HANDLE_MSG(hwndDlg, WM_COMMAND, RibbonDlg_OnCommand);
  41.         HANDLE_MSG(hwndDlg, WM_ENABLE, RibbonDlg_OnEnable);
  42.         HANDLE_MSG(hwndDlg, WM_PAINT, RibbonDlg_OnPaint);
  43.  
  44.     default:
  45.         return RibbonDlg_DefProc(hwndDlg, msg, wParam, lParam);
  46.     }
  47. }
  48.  
  49.  
  50.  
  51.  
  52. BOOL RibbonDlg_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
  53. {
  54.     HWND hCtl;
  55.     int i;
  56.  
  57.     // Add strings to the font combobox. 
  58.  
  59.     hCtl = GetDlgItem(hDlg, CTL_FONT);
  60.     i = IDS_FONT;
  61.  
  62.     while (LoadString(g_app.hinst, i++, g_app.szBuf, sizeof(g_app.szBuf)) != 0)
  63.         SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)(LPSTR)g_app.szBuf);
  64.     SendMessage(hCtl, CB_SETCURSEL, 0, 0);
  65.  
  66.     // Add strings to the fontsize combobox. 
  67.  
  68.     hCtl = GetDlgItem(hDlg, CTL_SIZE);
  69.     i = IDS_SIZE;
  70.  
  71.     while (LoadString(g_app.hinst, i++, g_app.szBuf, sizeof(g_app.szBuf)) != 0)
  72.         SendMessage(hCtl, CB_ADDSTRING, 0, (LONG)(LPSTR)g_app.szBuf);
  73.     SendMessage(hCtl, CB_SETCURSEL, 0, 0);
  74.  
  75.     return TRUE;
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  
  82. void RibbonDlg_OnEnable(HWND hDlg, BOOL fEnable)
  83. {
  84.     HWND hCtl;
  85.  
  86.     // Make all child windows have the same status as the dialog box. 
  87.  
  88.     hCtl = GetWindow(hDlg, GW_CHILD);
  89.  
  90.     while (hCtl != NULL) {
  91.         EnableWindow(hCtl, fEnable);
  92.         hCtl = GetWindow(hCtl, GW_HWNDNEXT);
  93.     }
  94. }
  95.  
  96.  
  97.  
  98.  
  99. void RibbonDlg_OnPaint(HWND hDlg)
  100. //----------------------------------------------------------------- 
  101. // Paint a horizontal dividing line between the Ribbon and the 
  102. // MDICLIENT window. 
  103. //----------------------------------------------------------------- 
  104. {
  105.     PAINTSTRUCT        ps;
  106.     HPEN            hPen;
  107.     RECT            rc;
  108.  
  109.     BeginPaint(hDlg, &ps);
  110.  
  111.     hPen = CreatePen(PS_SOLID, GetSystemMetrics(SM_CYBORDER), RGB(0, 0, 0));
  112.  
  113.     SelectObject(ps.hdc, hPen);
  114.     GetClientRect(hDlg, &rc);
  115.  
  116.     MoveTo(ps.hdc, 0, rc.bottom - GetSystemMetrics(SM_CYBORDER));
  117.     LineTo(ps.hdc, rc.right, rc.bottom - GetSystemMetrics(SM_CYBORDER));
  118.  
  119.     EndPaint(hDlg, &ps);
  120.     DeletePen(hPen);
  121. }
  122.  
  123.  
  124.  
  125.  
  126. void RibbonDlg_OnCommand(HWND hDlg, UINT id, HWND hWndCtl, UINT code)
  127. //----------------------------------------------------------------- 
  128. // Make sure that focus is given back to the Frame after an     
  129. // option is chosen by the user. 
  130. //----------------------------------------------------------------- 
  131. {
  132.     switch (id) {
  133.         case CTL_FONT:
  134.         case CTL_SIZE:
  135.         if (code != CBN_SELCHANGE)
  136.             break;
  137.         SetFocus(GetParent(hDlg));
  138.         break;
  139.  
  140.     case CTL_BOLD:
  141.     case CTL_ITALIC:
  142.     case CTL_UNDERLINE:
  143.         if (code != BN_CLICKED)
  144.             break;
  145.         SetFocus(GetParent(hDlg));
  146.         break;
  147.  
  148.     case IDOK:
  149.     case IDCANCEL:
  150.         SetFocus(GetParent(hDlg));
  151.         break;
  152.     }
  153. }
  154.